package com.baizhi.service;

import com.baizhi.annotations.RedisCache;
import com.baizhi.dao.PictureSwitchMapper;
import com.baizhi.entity.PictureSwitch;
import com.baizhi.entity.PictureSwitchExample;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service("pictureSwitchService")
@Transactional
public class PictureSwitchServiceImpl implements PictureSwitchService {

    @Resource
    private PictureSwitchMapper pictureSwitchMapper;
    PictureSwitchExample example = new PictureSwitchExample();
    @Override
    @RedisCache
    public List<PictureSwitch> findAll() {
        return pictureSwitchMapper.selectByExample(example);
    }

    @Override
    @RedisCache
    public PictureSwitch findById(String id) {
        return pictureSwitchMapper.selectByPrimaryKey(id);
    }

    @Override
    public void delete(String id) {
        pictureSwitchMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(PictureSwitch pictureSwitch) {
        pictureSwitchMapper.updateByPrimaryKey(pictureSwitch);
    }

    @Override
    public void save(PictureSwitch pictureSwitch) {
        pictureSwitchMapper.insert(pictureSwitch);
    }
}
